/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package converter;

/**
 *
 * @author user1
 */


public class Tablatura {
 
    public String row1 = "-";
    public String row2 = "-";
    public String row3 = "-";
    public String row4 = "-";
    public String row5 = "-";
    public String row6 = "-";
    
    public int max;
    
    public int [] result;
    
    public String [] result2;
    
    
    //Crea los arreglos para la tablatura a partir del numero de notas ingresadas
    
    public Tablatura(int max1){
        
        this.max = max1;
    
        result = new int [max1];
        result2 = new String [max1];
   
    }
    
 
    //Borra los Stings a imprimir, para poder modificar la partitura
    
    public void borrar(){
        
        row1 = "-";
        row2 = "-";
        row3 = "-";
        row4 = "-";
        row5 = "-";
        row6 = "-";
    }

    
    //Agrega una coordenada al arreglo de notas con Strings aimprimir
    
    public void addResult(int nota, int cuerda, int traste){
        
         String tras;
        
        if( nota< max){
            
                   
        
             this.result [nota] = cuerda;
        
             if (traste < 10){
            
                tras = Integer.toString(traste)+"--";
            
            
            }else{
            
                tras = Integer.toString(traste)+"-";
                
            }
        
            this.result2 [nota] = tras;
            
            
        }
        

        
        
    }
    
   
    //Contruye la partitura en los Stings row# a travez de el arreglo de notas y Strings 
    
    public void decode(){
        
        borrar();
        
        int contador;
        String proxa;
        
        for (contador = 0;contador < max; contador++ ){
            
            if(this.result[contador] == 0 ){
                
                proxa = this.result2[contador];
                row1 = row1+proxa;
                                              
                row2 = row2 + "----";
                row3 = row3 + "----";
                row4 = row4 + "----";
                row5 = row5 + "----";
                row6 = row6 + "----";
            
            }else if(this.result[contador] == 1 ){
                
                proxa = this.result2[contador];
                
                row2 = row2+proxa;
                row1 = row1 + "----";
                row3 = row3 + "----";
                row4 = row4 + "----";
                row5 = row5 + "----";
                row6 = row6 + "----";
                
                
            }else if(this.result[contador] == 2 ){
                
                proxa = this.result2[contador];
        
                row3 = row3+proxa;
                row1 = row1 + "----";
                row2 = row2 + "----";
                row4 = row4 + "----";
                row5 = row5 + "----";
                row6 = row6 + "----";
                
                
            }else if(this.result[contador] == 3 ){
                
                proxa = this.result2[contador];

                row4 = row4+proxa;
                row1 = row1 + "----";
                row3 = row3 + "----";
                row2 = row2 + "----";
                row5 = row5 + "----";
                row6 = row6 + "----";
                
                
            }else if(this.result[contador] == 4 ){
                
                proxa = this.result2[contador];
                row5 = row5+proxa;
                row1 = row1 + "----";
                row3 = row3 + "----";
                row4 = row4 + "----";
                row2 = row2 + "----";
                row6 = row6 + "----";
                
                
            }else if(this.result[contador] == 5 ){
                
                proxa = this.result2[contador];
                row6 = row6+proxa;
                row1 = row1 + "----";
                row3 = row3 + "----";
                row4 = row4 + "----";
                row2 = row2 + "----";
                row5 = row5 + "----";
                
                
            }else if(this.result[contador] == 6){
                
                row1 = row1 + "-|-";
                row2 = row2 + "-|-";
                row3 = row3 + "-|-";
                row4 = row4 + "-|-";
                row5 = row5 + "-|-";
                row6 = row6 + "-|-";
                
                
            }else if(this.result[contador] == 7){
                
                row1 = row1 + "-||-";
                row2 = row2 + "-||-";
                row3 = row3 + "-||-";
                row4 = row4 + "-||-";
                row5 = row5 + "-||-";
                row6 = row6 + "-||-";
                
                
            }              
                    
                    
                            
            
                
                
        }
        
        
        
        
    }
    
    
        
        
        
        
        
        
    }
    